<!DOCTYPE html>
<html lang=zh>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5" />
    <meta name="description" content="认识容器官方解释：  简而言之，容器是计算机上的沙盒进程，与主机上的所有其他进程隔离。。  是图像的可运行实例。您可以使用 DockerAPI 或 CLI 创建、启动、停止、移动或删除容器。  可以在本地计算机、虚拟机上运行或部署到云中。  是可移植的（可以在任何操作系统上运行）。  与其他容器隔离，并运行自己的软件、二进制文件和配置。    通俗解释：   容器就是一个存放东西的地方，可以是书包">
<meta property="og:type" content="article">
<meta property="og:title" content="初识Docker">
<meta property="og:url" content="https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/index.html">
<meta property="og:site_name" content="Cactus">
<meta property="og:description" content="认识容器官方解释：  简而言之，容器是计算机上的沙盒进程，与主机上的所有其他进程隔离。。  是图像的可运行实例。您可以使用 DockerAPI 或 CLI 创建、启动、停止、移动或删除容器。  可以在本地计算机、虚拟机上运行或部署到云中。  是可移植的（可以在任何操作系统上运行）。  与其他容器隔离，并运行自己的软件、二进制文件和配置。    通俗解释：   容器就是一个存放东西的地方，可以是书包">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/mihaoyou/pic-go/raw/master/img/202305210039206.png">
<meta property="og:image" content="https://camo.githubusercontent.com/8456039287cebc839e1f6fce7a4a4ee6743e67463d8bbed0d796ecf69c5fddbc/68747470733a2f2f6d792d626c6f672d746f2d7573652e6f73732d636e2d6265696a696e672e616c6979756e63732e636f6d2f323031392d372f646f636b65722545352539462542412545362539432541432545362541362538322545352542462542352e706e67">
<meta property="og:image" content="https://camo.githubusercontent.com/131f63ccb71eac168f3792759908cd604f64a165c397f3f4389f1788a76fbee4/68747470733a2f2f6f7363696d672e6f736368696e612e6e65742f6f73636e65742f75702d34313233613531353431313865316161616636653561303132383666343633613165322e706e67">
<meta property="article:published_time" content="2023-05-17T11:29:16.000Z">
<meta property="article:modified_time" content="2023-07-28T10:48:53.288Z">
<meta property="article:author" content="云雪">
<meta property="article:tag" content="Docker">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/mihaoyou/pic-go/raw/master/img/202305210039206.png">
    
    
      
        
          <link rel="shortcut icon" href="/images/favicon.ico">
        
      
      
        
          <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
        
      
      
        
          <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
        
      
    
    <!-- title -->
    <title>初识Docker</title>

    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">


     <!-- 添加到这里！！ -->
     
<script src="/js/switch.js"></script>


    <!-- persian styles -->
    
    <!-- rss -->
    
    
	<!-- mathjax -->
	
<meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Cactus" type="application/atom+xml">
</head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" aria-label="顶部" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
        <!--
       --><li><a href="/">首页</a></li><!--
     --><!--
       --><li><a href="/about/">关于</a></li><!--
     --><!--
       --><li><a href="/archives/">归档</a></li><!--
     --><!--
       --><li><a href="/categories/">分类</a></li><!--
     --><!--
       --><li><a href="/search/">搜索</a></li><!--
     -->
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" aria-label="上一篇" href="/Nginx%E9%85%8D%E7%BD%AE/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" aria-label="下一篇" href="/%E4%BD%BF%E7%94%A8Hadoop%E8%BF%9B%E8%A1%8C%E5%9C%86%E5%91%A8%E7%8E%87%E8%AE%A1%E7%AE%97/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" aria-label="返回顶部" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" aria-label="分享文章" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>

        <li><a class="icon" aria-label="切换主题 " href="#"><i class="fas fa-lightbulb" aria-hidden="true" onmouseover="$('#i-switch').toggle();" onmouseout="$('#i-switch').toggle();" onclick="switchNightMode();return false";></i></a></li>

      </ul>
      <span id="i-prev" class="info" style="display:none;">上一篇</span>
      <span id="i-next" class="info" style="display:none;">下一篇</span>
      <span id="i-top" class="info" style="display:none;">返回顶部</span>
      <span id="i-share" class="info" style="display:none;">分享文章</span>
      <span id="i-switch" class="info" style="display:none;">切换主题</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&text=初识Docker"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&is_video=false&description=初识Docker"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=初识Docker&body=Check out this article: https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&name=初识Docker&description="><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&t=初识Docker"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%A4%E8%AF%86%E5%AE%B9%E5%99%A8"><span class="toc-number">1.</span> <span class="toc-text">认识容器</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%98%E6%96%B9%E8%A7%A3%E9%87%8A%EF%BC%9A"><span class="toc-number">1.1.</span> <span class="toc-text">官方解释：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E4%BF%97%E8%A7%A3%E9%87%8A%EF%BC%9A"><span class="toc-number">1.2.</span> <span class="toc-text">通俗解释：</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%A4%E8%AF%86Docker"><span class="toc-number">2.</span> <span class="toc-text">认识Docker</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%EF%BC%9A"><span class="toc-number">2.1.</span> <span class="toc-text">工作原理：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E5%92%8C%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%9A%84%E5%8C%BA%E5%88%AB%EF%BC%9A"><span class="toc-number">2.2.</span> <span class="toc-text">Docker和虚拟机的区别：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E6%80%9D%E6%83%B3"><span class="toc-number">2.3.</span> <span class="toc-text">Docker思想</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E5%AE%B9%E5%99%A8%E7%9A%84%E7%89%B9%E7%82%B9%EF%BC%9A"><span class="toc-number">2.4.</span> <span class="toc-text">Docker容器的特点：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E6%A0%B8%E5%BF%83"><span class="toc-number">2.5.</span> <span class="toc-text">Docker核心</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E8%A7%81%E5%91%BD%E4%BB%A4"><span class="toc-number">3.</span> <span class="toc-text">常见命令</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Docker%E7%9A%84Build-Run%E5%92%8CShip"><span class="toc-number">4.</span> <span class="toc-text">Docker的Build,Run和Ship</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%89%A9%E5%B1%95%E6%9E%B6%E6%9E%84"><span class="toc-number">5.</span> <span class="toc-text">扩展架构</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker-Compose"><span class="toc-number">5.1.</span> <span class="toc-text">Docker Compose</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Compose%E6%96%87%E4%BB%B6"><span class="toc-number">5.2.</span> <span class="toc-text">Compose文件</span></a></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        初识Docker
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">云雪</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2023-05-17T11:29:16.000Z" itemprop="datePublished">2023-05-17</time>
        
      
    </div>


      
    <div class="article-category">
        <i class="fas fa-archive"></i>
        <a class="category-link" href="/categories/%E8%AF%BE%E5%A4%96%E6%8B%93%E5%B1%95/">课外拓展</a>
    </div>


      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link-link" href="/tags/Docker/" rel="tag">Docker</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h2 id="认识容器"><a href="#认识容器" class="headerlink" title="认识容器"></a>认识容器</h2><h3 id="官方解释："><a href="#官方解释：" class="headerlink" title="官方解释："></a><strong>官方解释：</strong></h3><blockquote>
<ul>
<li><p><strong>简而言之，容器是计算机上的沙盒进程，与主机上的所有其他进程隔离。。</strong></p>
</li>
<li><p><strong>是图像的可运行实例。您可以使用 DockerAPI 或 CLI 创建、启动、停止、移动或删除容器。</strong></p>
</li>
<li><p><strong>可以在本地计算机、虚拟机上运行或部署到云中。</strong></p>
</li>
<li><p><strong>是可移植的（可以在任何操作系统上运行）。</strong></p>
</li>
<li><p><strong>与其他容器隔离，并运行自己的软件、二进制文件和配置。</strong></p>
</li>
</ul>
</blockquote>
<h3 id="通俗解释："><a href="#通俗解释：" class="headerlink" title="通俗解释："></a><strong>通俗解释：</strong></h3><blockquote>
<p>  <strong>容器就是一个存放东西的地方，可以是书包，像书包一样装各种文具；也可以是衣柜，像衣柜一样可以放各种衣服；也可以是鞋架，像鞋架一样可以放各种鞋子一样。</strong></p>
</blockquote>
<h2 id="认识Docker"><a href="#认识Docker" class="headerlink" title="认识Docker"></a>认识Docker</h2><ul>
<li><p><img src="https://gitee.com/mihaoyou/pic-go/raw/master/img/202305210039206.png" alt="image-20230521003937454"></p>
<h3 id="工作原理："><a href="#工作原理：" class="headerlink" title="工作原理："></a>工作原理：</h3><p><strong>Docker</strong> 利用Linux核心中的资源分离机制，例如cgroups，以及Linux核心名字空间（namespaces），来创建独立的容器（containers）。这可以在单一Linux实体下运作，避免启动一个虚拟机造成的额外负担。Linux核心对名字空间的支持完全隔离了工作环境中应用程序的视野，包括行程树、网络、用户ID与挂载文件系统，而核心的cgroup提供资源隔离，包括CPU、存储器、block I&#x2F;O与网络。</p>
<h3 id="Docker和虚拟机的区别："><a href="#Docker和虚拟机的区别：" class="headerlink" title="Docker和虚拟机的区别："></a>Docker和虚拟机的区别：</h3><p><strong>Docker容器</strong>与虚拟机类似，但二者在原理上不同。<em><strong>容器是将操作系统层虚拟化，虚拟机则是虚拟化硬件，因此容器更具有便携性、更能高效地利用服务器。</strong></em> 容器更多的用于表示软件的一个标准化单元。由于容器的标准化，因此它可以无视基础设施（Infrastructure）的差异，部署到任何一个地方。另外，Docker也为容器提供更强的业界的隔离兼容。</p>
<h3 id="Docker思想"><a href="#Docker思想" class="headerlink" title="Docker思想"></a>Docker思想</h3><ol>
<li><p><strong>集装箱：</strong>集装箱之间相互隔离，快速装载和卸载，长期反复使用 。</p>
</li>
<li><p><strong>标准化：</strong>体现在运输方式、存储方式、API接口。</p>
</li>
<li><p><strong>隔离：</strong>和虚拟机一样，你分配了多少的硬盘内存CPU等，外面的机器感知不到，隔离开来了。</p>
</li>
</ol>
<h3 id="Docker容器的特点："><a href="#Docker容器的特点：" class="headerlink" title="Docker容器的特点："></a>Docker容器的特点：</h3><ol>
<li><p><strong>轻量</strong> : 在一台机器上运行的多个 Docker 容器可以共享这台机器的操作系统内核；它们能够迅速启动，只需占用很少的计算和内存资源。镜像是通过文件系统层进行构造的，并共享一些公共文件。这样就能尽量降低磁盘用量，并能更快地下载镜像。</p>
</li>
<li><p><strong>标准</strong> : Docker 容器基于开放式标准，能够在所有主流 Linux 版本、Microsoft Windows 以及包括 VM、裸机服务器和云在内的任何基础设施上运行。</p>
</li>
<li><p><strong>安全</strong> : Docker 赋予应用的隔离性不仅限于彼此隔离，还独立于底层的基础设施。Docker 默认提供最强的隔离，因此应用出现问题，也只是单个容器的问题，而不会波及到整台机器。</p>
</li>
</ol>
<h3 id="Docker核心"><a href="#Docker核心" class="headerlink" title="Docker核心"></a>Docker核心</h3><ul>
<li><p><strong>镜像（Image）</strong>：一个特殊的文件系统</p>
<blockquote>
<p><strong>操作系统分为内核和用户空间</strong>。对于 Linux 而言，内核启动后，会挂载 root 文件系统为其提供用户空间支持。而 Docker 镜像（Image），就相当于是一个 root 文件系统。</p>
<p><strong>Docker 镜像是一个特殊的文件系统，除了提供容器运行时所需的程序、库、资源、配置等文件外，还包含了一些为运行时准备的一些配置参数（如匿名卷、环境变量、用户等）。</strong> 镜像不包含任何动态数据，其内容在构建之后也不会被改变</p>
</blockquote>
</li>
<li><p><strong>容器（Container）</strong>：镜像运行时的实体</p>
<blockquote>
<p>镜像（Image）和容器（Container）的关系，就像是面向对象程序设计中的 类 和 实例 一样，镜像是静态的定义，<strong>容器是镜像运行时的实体。容器可以被创建、启动、停止、删除、暂停等</strong> 。</p>
</blockquote>
</li>
<li><p><strong>仓库（Repository）</strong>：集中存放镜像文件的地方</p>
<blockquote>
<p>一个 Docker Registry 中可以包含多个仓库（Repository）；每个仓库可以包含多个标签（Tag）；每个标签对应一个镜像。所以说：<strong>镜像仓库是 Docker 用来集中存放镜像文件的地方类似于我们之前常用的代码仓库。一个仓库会包含同一个软件不同版本的镜像</strong>，而<strong>标签就常用于对应该软件的各个版本</strong> 。</p>
</blockquote>
</li>
</ul>
<img src="https://camo.githubusercontent.com/8456039287cebc839e1f6fce7a4a4ee6743e67463d8bbed0d796ecf69c5fddbc/68747470733a2f2f6d792d626c6f672d746f2d7573652e6f73732d636e2d6265696a696e672e616c6979756e63732e636f6d2f323031392d372f646f636b65722545352539462542412545362539432541432545362541362538322545352542462542352e706e67" alt="img" style="zoom:80%;" />

<h2 id="常见命令"><a href="#常见命令" class="headerlink" title="常见命令"></a>常见命令</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">docker version # 查看docker版本</span><br><span class="line">docker images # 查看所有已下载镜像，等价于：docker image ls 命令</span><br><span class="line">docker container ls # 查看所有容器</span><br><span class="line">docker ps #查看正在运行的容器</span><br><span class="line">docker image prune # 清理临时的、没有被使用的镜像文件。-a, --all: 删除所有没有用的镜像，而不仅仅是临时文件；</span><br><span class="line">docker search mysql # 查看mysql相关镜像</span><br><span class="line">docker pull mysql:5.7 # 拉取mysql镜像</span><br><span class="line">docker image ls # 查看所有已下载镜像</span><br></pre></td></tr></table></figure>

<h2 id="Docker的Build-Run和Ship"><a href="#Docker的Build-Run和Ship" class="headerlink" title="Docker的Build,Run和Ship"></a>Docker的Build,Run和Ship</h2><p><strong>Docker 的概念以及常见命令基本上已经讲完，我们再来谈谈：Build, Ship, and Run。</strong></p>
<p>如果你搜索 Docker 官网，会发现如下的字样：<strong>“Docker - Build, Ship, and Run Any App, Anywhere”</strong>。那么 Build, Ship, and Run 到底是在干什么呢？</p>
<p><a target="_blank" rel="noopener" href="https://camo.githubusercontent.com/131f63ccb71eac168f3792759908cd604f64a165c397f3f4389f1788a76fbee4/68747470733a2f2f6f7363696d672e6f736368696e612e6e65742f6f73636e65742f75702d34313233613531353431313865316161616636653561303132383666343633613165322e706e67"><img src="https://camo.githubusercontent.com/131f63ccb71eac168f3792759908cd604f64a165c397f3f4389f1788a76fbee4/68747470733a2f2f6f7363696d672e6f736368696e612e6e65742f6f73636e65742f75702d34313233613531353431313865316161616636653561303132383666343633613165322e706e67" alt="img"></a></p>
<ul>
<li><strong>Build（构建镜像）</strong>：镜像就像是集装箱包括文件以及运行环境等等资源。</li>
<li><strong>Ship（运输镜像）</strong>：主机和仓库间运输，这里的仓库就像是超级码头一样。</li>
<li><strong>Run （运行镜像）</strong>：运行的镜像就是一个容器，容器就是运行程序的地方。</li>
</ul>
<p><strong>Docker 运行过程也就是去仓库把镜像拉到本地，然后用一条命令把镜像运行起来变成容器。所以，我们也常常将 Docker 称为码头工人或码头装卸工，这和 Docker 的中文翻译搬运工人如出一辙。</strong></p>
<h2 id="扩展架构"><a href="#扩展架构" class="headerlink" title="扩展架构"></a>扩展架构</h2><h3 id="Docker-Compose"><a href="#Docker-Compose" class="headerlink" title="Docker Compose"></a>Docker Compose</h3><p>Compose可译为组合物。Compose 是用于定义和运行 多个容器Docker应用程序 的工具。通过Compose，你可以使用YAML文件来配置应用程序需要的所有服务，然后通过使用一个命令，就可以创建并启动所有服务。Compose对应的命令为<code>docker-compose</code>。</p>
<h3 id="Compose文件"><a href="#Compose文件" class="headerlink" title="Compose文件"></a>Compose文件</h3><p>Compose文件 是一个YAML文件，定义了服务（service）、网络、卷（volume）。</p>
<ul>
<li><strong>服务（service）</strong>定义 各容器的配置，定义内容将以命令行参数的方式 传给 <code>docker run</code> 命令。</li>
<li><strong>网络（network）</strong>，类似地，将定义内容传给 <code>docker network create</code> 命令 。</li>
<li><strong>卷（volume）</strong>，类似地，将定义内容传给 <code>docker volume create</code> 命令。</li>
</ul>
</li>
</ul>

  </div>
  <div id="copyright"><style>#easter-egg{border:0;padding:10px 0;position:relative}#easter-egg::before{font-family:"Font Awesome 5 Free";font-weight:900;content:"本文结束 \f1b0  感谢阅读";position:absolute;
padding:0 10px;
line-height:1px;
white-space:nowrap;
left:50%;
transform:translateX(-50%)}
</style><hr id="easter-egg"><blockquote style="padding:0">
    <p>作者: <a href="https://mihaoyou.gitee.io">
        <a1>云静</a1>
    </a></p>
    <p>版权声明: 本博客所有文章除特别声明外, 均采用 <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)"><a1>CC BY-NC-ND 4.0</a1></a> 许可协议, 转载请注明出处！</p></blockquote><hr></div>
</article>


    <div class="blog-post-comments">
        <div id="utterances_thread">
            <noscript>加载评论需要在浏览器启用 JavaScript 脚本支持。</noscript>
        </div>
    </div>


        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">首页</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/search/">搜索</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%A4%E8%AF%86%E5%AE%B9%E5%99%A8"><span class="toc-number">1.</span> <span class="toc-text">认识容器</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%98%E6%96%B9%E8%A7%A3%E9%87%8A%EF%BC%9A"><span class="toc-number">1.1.</span> <span class="toc-text">官方解释：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%9A%E4%BF%97%E8%A7%A3%E9%87%8A%EF%BC%9A"><span class="toc-number">1.2.</span> <span class="toc-text">通俗解释：</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%A4%E8%AF%86Docker"><span class="toc-number">2.</span> <span class="toc-text">认识Docker</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86%EF%BC%9A"><span class="toc-number">2.1.</span> <span class="toc-text">工作原理：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E5%92%8C%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%9A%84%E5%8C%BA%E5%88%AB%EF%BC%9A"><span class="toc-number">2.2.</span> <span class="toc-text">Docker和虚拟机的区别：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E6%80%9D%E6%83%B3"><span class="toc-number">2.3.</span> <span class="toc-text">Docker思想</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E5%AE%B9%E5%99%A8%E7%9A%84%E7%89%B9%E7%82%B9%EF%BC%9A"><span class="toc-number">2.4.</span> <span class="toc-text">Docker容器的特点：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker%E6%A0%B8%E5%BF%83"><span class="toc-number">2.5.</span> <span class="toc-text">Docker核心</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B8%B8%E8%A7%81%E5%91%BD%E4%BB%A4"><span class="toc-number">3.</span> <span class="toc-text">常见命令</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Docker%E7%9A%84Build-Run%E5%92%8CShip"><span class="toc-number">4.</span> <span class="toc-text">Docker的Build,Run和Ship</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%89%A9%E5%B1%95%E6%9E%B6%E6%9E%84"><span class="toc-number">5.</span> <span class="toc-text">扩展架构</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker-Compose"><span class="toc-number">5.1.</span> <span class="toc-text">Docker Compose</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Compose%E6%96%87%E4%BB%B6"><span class="toc-number">5.2.</span> <span class="toc-text">Compose文件</span></a></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&text=初识Docker"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&is_video=false&description=初识Docker"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=初识Docker&body=Check out this article: https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&title=初识Docker"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&name=初识Docker&description="><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://mihaoyou.gitee.io/%E5%88%9D%E8%AF%86Docker/&t=初识Docker"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> 菜单</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> 目录</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> 分享</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> 返回顶部</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
      <div class="footer-left">
        Copyright &copy;
        
        
        2022-2023
        云雪
      </div>
      <div class="footer-right">
        <nav>
          <ul>
            <!--
          --><li><a href="/">首页</a></li><!--
        --><!--
          --><li><a href="/about/">关于</a></li><!--
        --><!--
          --><li><a href="/archives/">归档</a></li><!--
        --><!--
          --><li><a href="/categories/">分类</a></li><!--
        --><!--
          --><li><a href="/search/">搜索</a></li><!--
        -->
          </ul>
          <ul>
          
              <!-- 不蒜子统计 -->
              <span id="busuanzi_container_site_pv">
                  本站总访问量<span id="busuanzi_value_site_pv"></span>次
              </span>
              <span class="post-meta-divider">|</span>
              <span id="busuanzi_container_site_uv" style='display:none'>
                      本站访客数<span id="busuanzi_value_site_uv"></span>人
              </span>
            <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            
          </ul>
        </nav>
      </div>
      
</footer>


    </div>
    <!-- styles -->



  <link rel="preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" crossorigin="anonymous" onload="this.onload=null;this.rel='stylesheet'"/>


    <!-- jquery -->
 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script> 




<!-- clipboard -->

  
    <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.7/clipboard.min.js" crossorigin="anonymous"></script> 
  
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"复制到粘贴板！\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "复制成功！");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

  <script type="text/javascript">
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?d052d72734717a430b46e4d07257350b";
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(hm, s);
        })();
        </script>

<!-- Cloudflare Analytics -->

<!-- Umami Analytics -->

<!-- Disqus Comments -->

<!-- utterances Comments -->

    <script type="text/javascript">
      var utterances_repo = 'mihaoyou/huayu';
      var utterances_issue_term = 'pathname';
      var utterances_label = 'Comment';
      var utterances_theme = 'github-dark';

      (function(){
          var script = document.createElement('script');

          script.src = 'https://utteranc.es/client.js';
          script.setAttribute('repo', utterances_repo);
          script.setAttribute('issue-term', 'pathname');
          script.setAttribute('label', utterances_label);
          script.setAttribute('theme', utterances_theme);
          script.setAttribute('crossorigin', 'anonymous');
          script.async = true;
          (document.getElementById('utterances_thread')).appendChild(script);
      }());
  </script>

</body>
</html>
